package br.com.foxline.atlasmobile.converter;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


import br.com.foxline.model.Registration;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

/**
 *
 * @author lucianokelvin
 */
@FacesConverter(value = "registrationconverter")
public class RegistrationConverter implements Converter{
    
     @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value) {
        Registration registration = new Registration();
        if(!value.equals("") && !value.equals("null"))
         registration.setId((Long.valueOf(value)));
        return registration ;
    }

    @Override
    public String getAsString(FacesContext context, UIComponent component, Object value) {
        if(value == null || value.equals("")){
            return "";
        }
        Registration registration = (Registration) value;
        return "" + registration.getId();
    }
    
}
